import Vue from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store";
import "lib-flexible";

/** 注册全局svg组件 */
import SvgIcon from "@/components/SvgIcon/index.vue";
import "@/components/SvgIcon/index";
Vue.component("svg-icon", SvgIcon);

// vant 预览图片组件
import { ImagePreview } from "vant";
Vue.prototype.$ImagePreview = ImagePreview;

/**注册自定义组件 */
const componentsReq = require.context("./components", true, /\.vue$/);
componentsReq.keys().forEach((key) => {
  const component = componentsReq(key).default;
  Vue.component(component.name, component);
});

Vue.config.productionTip = false;

import {
  Toast,
  Button,
  NavBar,
  Tabbar,
  TabbarItem,
  Lazyload,
  Image,
  Icon,
  Tab,
  Tabs,
  List,
  PullRefresh,
  Cell,
  CellGroup,
  Dialog,
  Field,
  Search,
  Collapse,
  CollapseItem,
  Popup,
  DatetimePicker,
  Picker,
  Checkbox,
  CheckboxGroup,
  Divider,
  Radio,
  RadioGroup,
  Uploader,
  NoticeBar,
  Swipe,
  SwipeItem,
  DropdownMenu,
  DropdownItem,
  TreeSelect,
  Badge,
  Calendar,
  ActionSheet,
  Empty,
  Notify,
} from "vant";

Vue.config.productionTip = false;

Vue.use(Button)
  .use(Notify)
  .use(Toast)
  .use(Empty)
  .use(Calendar)
  .use(ActionSheet)
  .use(NavBar)
  .use(TabbarItem)
  .use(Icon)
  .use(Tabbar)
  .use(Lazyload)
  .use(Image)
  .use(Badge)
  .use(Tab)
  .use(Tabs)
  .use(List)
  .use(PullRefresh)
  .use(Cell)
  .use(CellGroup)
  .use(Dialog)
  .use(Field)
  .use(Search)
  .use(Collapse)
  .use(CollapseItem)
  .use(Popup)
  .use(DatetimePicker)
  .use(Picker)
  .use(CheckboxGroup)
  .use(Checkbox)
  .use(Divider)
  .use(RadioGroup)
  .use(Radio)
  .use(Uploader)
  .use(NoticeBar)
  .use(Swipe)
  .use(SwipeItem)
  .use(DropdownMenu)
  .use(DropdownItem)
  .use(TreeSelect);

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
